package com.itheima.demo;

import com.itheima.doman.Student;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class CollectionDemo2 {
    public static void main(String[] args) {
        Collection<Student> sc = new ArrayList<>();
        sc.add(new Student("张三",32,"男"));
        sc.add(new Student("李四",38,"男"));
        sc.add(new Student("王麻子",32,"男"));
        sc.add(new Student("赵六",22,"男"));
        sc.add(new Student("死瘸子",92,"男"));
        sc.add(new Student("田七",38,"男"));
        sc.add(new Student("天乖戾",34,"男"));
        Iterator<Student> iterator = sc.iterator();
        while (iterator.hasNext()){
            if (iterator.next().getName().length()>2){
                iterator.remove();
            }
        }
        for (Student student : sc) {
            System.out.println(student);
        }
    }


}
